<script type="text/javascript" src="paging.js"></script>

<?php
	include_once "../classes/hocvien_bs.php";
	
	$Status  = (int)$_GET['sta'];
	$Page    = $_GET['pag'];
	$Keyword = $_GET['key'];
	
	$HocVien = new hocvien_bs();
	$HocVien->SetDaXoa(0);
	if($Status == 0 || $Status == 1 || $Status == 2 )
		$HocVien->SetMaTrangThai($Status);
	if($Keyword != '')
		$HocVien->SetHoTen(trim($Keyword));
	$DHocVien = $HocVien->LayDanhSach();
	$Limit = 20;
	$SoTrang = ceil(count($DHocVien) / $Limit);
	
	$DHocVien = $HocVien->LayDanhSachPaging(($Page - 1) * $Limit, $Limit);
?>
<div class="Paging">
	<?php
		if($DHocVien != null)
		{
			if($Page > 1)
				echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",1);'>Đầu</a>";	
			for($i = 1; $i <= $SoTrang; $i++)
			{
				if($Page - 5 <= $i && $i <= $Page + 5)
				{
					if($i == $Page)
						echo "<a class='AjaxPageCur' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>$i</a>";
					else
						echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>$i</a>";
				}
				elseif($i == $Page + 6)
					echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>...</a>";
				elseif($i == $Page - 6)
					echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>...</a>";
			}
			if($Page < $SoTrang)
				echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$SoTrang);'>Cuối</a>";	
			
			echo "<span style='float:right; background-color:#4ABDF4; color: #FFF; padding:0px 3px'>Trang $Page/$SoTrang</span>";
		}
	?>
</div>
<div id="KetQuaTimKiem">
	<?php
		include_once "hocvien_timkiem_page.php";
	?>
</div>
<div class="Paging">
	<?php
		if($DHocVien != null)
		{
			if($Page > 1)
				echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",1);'>Đầu</a>";	
			for($i = 1; $i <= $SoTrang; $i++)
			{
				if($Page - 5 <= $i && $i <= $Page + 5)
				{
					if($i == $Page)
						echo "<a class='AjaxPageCur' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>$i</a>";
					else
						echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>$i</a>";
				}
				elseif($i == $Page + 6)
					echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>...</a>";
				elseif($i == $Page - 6)
					echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$i);'>...</a>";
			}
			if($Page < $SoTrang)
				echo "<a class='AjaxPage' href='#' onclick='javascript:loadXMLDoc($Status,\"$Keyword\",$SoTrang);'>Cuối</a>";	
			
			echo "<span style='float:right; background-color:#4ABDF4; color: #FFF; padding:0px 3px'>Trang $Page/$SoTrang</span>";
		}
	?>
</div>


